handle non-finite bounds in BigIntegerValidator range checks#414
Open
sahvx655-wq wants to merge 1 commit into
Open
handle non-finite bounds in BigIntegerValidator range checks#414sahvx655-wq wants to merge 1 commit into
sahvx655-wq wants to merge 1 commit into
Conversation
Member
|
Please keep track of what is happening to your existing PRs: #410 has been broken for almost a week. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BigIntegerValidator's minValue(Number, Number) and maxValue(Number, Number) compare the operands as BigDecimal, but unlike the equivalent BigDecimalValidator overloads they never guard for a non-finite bound. A Double.NaN, POSITIVE_INFINITY or NEGATIVE_INFINITY argument is routed straight into BigDecimal.valueOf(double), which cannot represent those values and throws NumberFormatException, so the call (and the inherited isInRange that delegates to it) blows up with an undeclared exception rather than returning a boolean. I traced this from an open-ended range check where an infinite upper bound threw instead of accepting every finite value; BigDecimalValidator accepts the same bound without complaint, so the two validators disagree.
The fix guards both overrides with isFinite and falls back to the doubleValue() comparison when either operand is non-finite, mirroring BigDecimalValidator. The finite path is untouched, so the exact-magnitude and fractional-bound behaviour stays as it was; only the previously-throwing case changes, with a NaN bound never satisfied and an infinity treated as an open bound. Keeping the guard in the callee means every entry point stays consistent without callers having to sanitise their bounds first.